/*
Copyright (C) 2022-2024 Inspur Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/
package apicheck

import (
	"did-service/plugins/apicheck/impl"
	"did-service/plugins/apicheck/param"
)

var apiChecker *ApiChecker

type ApiChecker struct {
	Plugin ApiCheckerPlugin
}

type ApiCheckerPlugin interface {
	ExtractPayload(input interface{}) string
	CheckSignature(param *param.ApiCheckParam) bool
}

func Init() {
	apiChecker = &ApiChecker{
		Plugin: impl.NewBaseApiChecker(),
	}
}

func Get() *ApiChecker {
	return apiChecker
}

func (checker *ApiChecker) ExtractPayload(input interface{}) string {
	return checker.Plugin.ExtractPayload(input)
}

func (checker *ApiChecker) CheckSignature(param *param.ApiCheckParam) bool {
	return checker.Plugin.CheckSignature(param)
}
